package com.jt.aop;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.jt.pojo.ItemParam;
import com.jt.vo.ItemParamVO;
import org.junit.Test;

import java.util.ArrayList;
import java.util.List;

public class AAA {

    @Test
    public void toJson() throws JsonProcessingException {

        ObjectMapper mapper = new ObjectMapper();

        ItemParamVO itemParam = new ItemParamVO();

        itemParam.setParamId(1);
        itemParam.setParamVals("100");
        ItemParamVO itemParamVO = new ItemParamVO();
        itemParamVO.setParamId(2);
        itemParamVO.setParamVals("200");
        List list = new ArrayList();
        list.add(itemParam);
        list.add(itemParamVO);
        String json = mapper.writeValueAsString(list);
        String json2 = mapper.writeValueAsString(itemParam);
        System.out.println(json2);
        System.out.println(json);

        List o = mapper.readValue(json,List.class);
        System.out.println(o);


    }


}
